package com.aliyun;

/**
 * Created by liuhai.lh on 17/01/12.
 */
public class BaseSample {

    protected static String accessKeyId;
    protected static String accessKeySecret;

    protected static String regionId;

    static {
//        Properties properties = new Properties();
//
//        try {
//            properties.load(BaseSample.class.getResourceAsStream("config.properties"));
//            accessKeyId = properties.getProperty("accessKeyId");
//            accessKeySecret = properties.getProperty("accessKeySecret");
//            regionId = properties.getProperty("regionId");
//        } catch(IOException e) {
//            e.printStackTrace();
//        }

        // 该类（包含继承类）第一次被调用时执行静态块方法，先执行静态块方法，再执行调用方法
        accessKeyId = "LTAI4FdXvB5oEiKhv7V2Fhjs";
        accessKeySecret = "gCePJ9XdCV38OrdSPCQxnqmqm4o5sv";
        regionId="cn-shanghai";

    }

    protected static String getDomain(){
         if("cn-shanghai".equals(regionId)){
             return "green.cn-shanghai.aliyuncs.com";
         }

         if ("cn-beijing".equals(regionId)) {
            return "green.cn-beijing.aliyuncs.com";
         }

         if ("ap-southeast-1".equals(regionId)) {
            return "green.ap-southeast-1.aliyuncs.com";
         }

         if ("us-west-1".equals(regionId)) {
            return "green.us-west-1.aliyuncs.com";
         }

         return "green.cn-shanghai.aliyuncs.com";
    }

    protected static String getEndPointName(){
        return regionId;
    }

}
